package com.hmall.trade.listener;

import com.alibaba.nacos.shaded.com.google.protobuf.Message;
import com.hmall.trade.domain.po.Order;
import com.hmall.trade.enums.PayStatus;
import com.hmall.trade.service.IOrderService;
import lombok.RequiredArgsConstructor;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * @className:PayStatusListener
 * @date: 2025/7/9 下午6:15
 * @description:
 */
@Component
@RabbitListener
@RequiredArgsConstructor
public class PayStatusListener {
    private final IOrderService orderService;

    @RabbitListener(bindings = @QueueBinding(exchange = @Exchange(name = "pay.topic"),
            value = @Queue(name = "trade.pay.success.queue", durable = "true"),
            key = "pay.success"
    ))
    public void listenPaySuccess(Long orderId) {
        orderService.markOrderPaySuccess(orderId);
    }
}
